<template>
  <div>
    <h1>rose</h1>
    <button @click="give">将rose的msg传递给Jack</button>
    <!--   <p>{{ info }}</p>
    <p>{{ obj }}</p> -->
    <p>{{ name }}</p>
    <p>{{ info }}</p>
  </div>
</template>

<script>
/* $emit $on eventBus 可以任意组件进行传值
公共的对象 空的vue实例
使用$emit的组件有值，发送数据
使用$on绑定事件及回调函数，接收数据
*/
import eventBus from "../../utils/eventBus";
export default {
  name: "",
  props: [""],
  data() {
    return {
      msg: "rose的数据"
    };
  },

  components: {},

  computed: {},

  beforeMount() {},

  mounted() {},
  // inject: ["info", "obj"],
  inject: ["name", "info"],
  methods: {
    give() {
      eventBus.$emit("giveMsg", this.msg);
    }
  },

  watch: {}
};
</script>
<style lang="" scoped></style>
